<?php /** @noinspection PhpMissingReturnTypeInspection */
/** @noinspection PhpMixedReturnTypeCanBeReducedInspection */
/** @noinspection PhpMissingDocCommentInspection */
/** @noinspection PhpUnusedParameterInspection */
/** @noinspection PhpDocSignatureIsNotCompleteInspection */

declare(strict_types=1);

namespace Dreamcat\ApiDocTest\Demo\Ctl;

use Dreamcat\ApiDoc\Annotations\ApiModelProperty;
use Dreamcat\ApiDoc\Annotations\ApiOperation;
use Dreamcat\ApiDoc\Annotations\ControllerTag;
use Dreamcat\ApiDoc\Annotations\IgnoreParam;
use Dreamcat\ApiDoc\Annotations\MapModelDesc;
use Dreamcat\ApiDocTest\Demo\Popo\AutoGetObj;
use Dreamcat\ApiDocTest\Demo\Popo\IgnoreType;
use Dreamcat\ApiDocTest\Demo\Popo\Obj1;
use Dreamcat\ApiDocTest\Demo\Popo\PathO;
use Dreamcat\ApiDocTest\Demo\Popo\ReqBody;
use Dreamcat\ApiDocTest\Demo\Popo\Result;
use DreamCat\ControllerParamGen\Annotation\CtlParamType;
use DreamCat\ObjectValid\Annotation\Size;
use Dreamcat\PropertyAnalysis\Annotation\ArrayDescAnno;
use JetBrains\PhpStorm\Pure;
use Psr\Http\Message\RequestInterface;
use Psr\Log\LoggerInterface;
use stdClass;

/**
 * demo控制器
 * @author vijay
 */
#[ControllerTag("新标签")]
class DemoController
{
    #[Pure]
    #[ApiOperation("看看效果的接口", "病例")]
    public function index(
        #[CtlParamType(CtlParamType::TYPE_PATH_VARIABLE)]
        #[ApiModelProperty("订单号", "03480194857")]
        string $path1,
        #[ApiModelProperty("商品号", "154372")]
        string $path2,
        #[CtlParamType]
        ReqBody $reqBody,
        #[IgnoreParam]
        string|null $ignoreParam
    ): Result {
        return new Result();
    }

    /**
     * 没api注解，没返回值的情况
     * @return void
     */
    public function noA(
        #[CtlParamType(CtlParamType::TYPE_PATH_VARIABLE)]
        PathO $obj3,
        RequestInterface $request
    ): void {

    }

    #[ApiOperation("测试没定义返回值的情况", "noDef", "desc看看")]
    public function noDefRes($unknowType, bool $b)
    {
    }

    #[ApiOperation("多级get", desc: "看看多级路径的get")]
    public function comGet(
        #[CtlParamType(CtlParamType::TYPE_GET_PARAM, "cc/aa/dd")]
        #[ApiModelProperty("多级get", "@integer(1, 23)", "5")]
        int $get,
        #[CtlParamType(CtlParamType::TYPE_GET_PARAM)]
        Obj1 $obj1,
        #[CtlParamType(CtlParamType::TYPE_GET_PARAM, "o2/er/a")]
        Obj1 $obj2,
        IgnoreType $ignoreType,
        AutoGetObj $autoGetObj,
        bool $autoBool
    ): string {
        return uniqid("com");
    }

    #[ApiOperation("测试返回值为数字")]
    public function returnNumber(): int
    {
        # 就是要测试没参数的场景，不要再加参数了
        return 0;
    }

    #[ApiOperation("测试返回值为mixed")]
    public function returnMixed(
        #[CtlParamType] stdClass $class,
        #[CtlParamType(CtlParamType::TYPE_HEADER)]
        string $hv,
        #[CtlParamType(CtlParamType::TYPE_COOKIE)]
        string $cv,
        #[CtlParamType(CtlParamType::TYPE_GET_PARAM)]
        string $getV,
        string $autoPath
    ): mixed {
        return [];
    }

    #[ApiOperation("测试返回数组")]
    public function returnArray(
        #[CtlParamType(path: "body/ame/rmtk/x")]
        $xman,
        #[CtlParamType(path: "body/ame/tt")]
        int $yman,
        #[ApiModelProperty("无法解析的类型测试")]
        LoggerInterface $logger
    ): array
    {
        return [];
    }

    #[ApiOperation("测试用map做请求体")]
    public function useMapParam(
        #[ApiModelProperty("关联的用户信息")]
        #[ArrayDescAnno(Obj1::class)]
        #[MapModelDesc("uid", "用户信息")]
        #[CtlParamType]
        #[Size(3, 6)]
        array $m
    ):void{

    }
}

# end of file
